package com.service.business.support;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * <dl>
 * <dt>platform</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2018</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019-04-20</dd>
 * </dl>
 */

public class CommonMethod {

    @Setter
    @Getter
    public static class ConsumeLevel {
        private Integer id;

        private String name;

        private Integer multiple;

        private BigDecimal rate;

    }


    private static final List<ConsumeLevel> consumeLevelList = new ArrayList<>();
    static {
        ConsumeLevel consumeLevel = new ConsumeLevel();
        consumeLevel.setId(1);
        consumeLevel.setName("积分区");
        consumeLevel.setMultiple(0);
        consumeLevel.setRate(new BigDecimal(0));
        consumeLevelList.add(consumeLevel);

        consumeLevel = new ConsumeLevel();
        consumeLevel.setId(2);
        consumeLevel.setName("消费区");
        consumeLevel.setMultiple(0);
        consumeLevel.setRate(new BigDecimal(0.4d));
        consumeLevelList.add(consumeLevel);


        consumeLevel = new ConsumeLevel();
        consumeLevel.setId(3);
        consumeLevel.setName("增值区");
        consumeLevel.setMultiple(1);
        consumeLevel.setRate(new BigDecimal(0.8d));
        consumeLevelList.add(consumeLevel);
    }


    /**
     * 获取等级
     * @param id
     * @return
     */
    public static ConsumeLevel getConsumeLevel(Integer id) {

        for (ConsumeLevel consumeLevel : consumeLevelList) {
            if (id.equals(consumeLevel.getId())) {
                return consumeLevel;
            }
        }
        return null;
    }
}
